<?php 
namespace app\wap\controller;

use cmf\controller\WapController;
use app\wap\model\PaymentsModel;
class IndexController extends WapController{
	public function initialize()
    {
        parent::initialize();
    }
	public function index(){
		return $this->fetch('index');
	}
	public function payment($total=null){
		$total = format_free($total);
		if($total <= 0){
			$this->error("收款金额不能为空");
		}
		$payments = new PaymentsModel();
		$aisle = $payments->getAisle();
		$aisles = [];
		if($aisle){
			foreach($aisle as $v){
				$v['disbale'] = 0;
				if(!empty($v['time']) ){
					list($nimTime,$maxTime) = explode("-",$v['time']);
					if(!empty($nimTime) && time() < strtotime(date('Y-m-d ',time()).$nimTime)){
						$v['disbale'] = 1;
					}
					if(!empty($nimTime) && time() > strtotime(date('Y-m-d ',time()).$maxTime)){
						$v['disbale'] = 1;
					}
				}
				if($v['minmoney'] > $total || $total > $v['maxmoney']){
					$v['disbale'] = 1;
				}
				$aisles[] = $v;
			}
		}
		$cards = db('user_cards')->where(['user_id'=>$this->userId])->field("id,user_id,bankAccountNo,openBankName,bankAccountName,expDate,cvn2")->select();
		$this->assign('total',$total);
		$this->assign('cards',$cards);
		$this->assign('aisles',$aisles);
		return $this->fetch();
	}
	public function t(){
		return $this->fetch();
	}
}
?>